package cn.zhentao.controller;

import cn.zhentao.pojo.Doctor;
import cn.zhentao.pojo.Pet;
import cn.zhentao.service.PetService;
import cn.zhentao.vo.ZhVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.rmi.server.UID;
import java.util.List;

@RestController
@RequestMapping("/pet")
public class PetController {
@Autowired
    private PetService petService;
//=====tj
@PostMapping("/add")
public void addpet(@RequestBody Pet pet){
    petService.addpet(pet);
}
//=====xg
@PostMapping("/update")
public int update(@RequestBody Pet pet){
    petService.updatep(pet);
    return 1;
}
//=====cx
@GetMapping("/findp")
public PageInfo<Pet> finda(@RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize")Integer pageSize,@RequestParam String pname){
    PageHelper.startPage(pageNum,pageSize);
    List<Pet> findp = petService.findp(pname);
    PageInfo<Pet> petPageInfo = new PageInfo<>(findp);
    return petPageInfo;
}

//=====Pldel
@DeleteMapping("/delp")
public int del(@RequestBody Integer [] uid){
    int delp = petService.delp(uid);
    return delp;
}
//=====mo
@PostMapping("/findmo")
public List<Pet>findmo(@RequestBody String pname){
    List<Pet> finmo = petService.finmo(pname);
    return finmo;
}
//=====uid
@PostMapping("/findz")
public List<Pet>findz(@RequestParam Integer uid){
    List<Pet> findz = petService.findz(uid);
    return findz;
}
//=====del
@DeleteMapping("/del")
public int delp(@RequestParam Integer uid){
    int del = petService.del(uid);
    return del;
}
//=====update
@PostMapping("/upd")
public int upd(@RequestParam Integer pid,@RequestParam Integer pill,@RequestParam Integer uid){
    petService.update(pid,pill,uid);
    return 1;
}
}
